package edu.hitsz.shoot;

import edu.hitsz.bullet.BaseBullet;
import edu.hitsz.bullet.EnemyBullet;

import java.util.LinkedList;
import java.util.List;

public class ShootScatteringByEnemy extends ShootStrategy{
    public ShootScatteringByEnemy() {}

    @Override
    public List<BaseBullet> shoot(int locationX, int locationY, int speedY, int shootNum, int power, int direction) {
        List<BaseBullet> res = new LinkedList<>();

        // 获取子弹初始位置
        int x = locationX;
        int y = locationY + direction*2;
        // 获取子弹发射速度 方向
        int speedX = -2;
        speedY += direction*5;

        BaseBullet baseBullet;
        for(int i=0; i<shootNum; ++i){
            // 子弹发射位置相对飞机位置向前偏移
            // 多个子弹横向分散
            baseBullet = new EnemyBullet(x + (i*2 - shootNum + 1)*10, y, speedX, speedY, power);
            speedX += 2;
            res.add(baseBullet);
        }
        return res;
    }
}
